//
//  MPBTools+UserDefaults.m
//  MiaoPai
//
//  Created by jiaxuzhou on 2017/6/10.
//  Copyright © 2017年 Jeakin. All rights reserved.
//
//


#import "MPBTools+UserDefaults.h"


#define MPT_UserDefaults [NSUserDefaults standardUserDefaults]


@implementation MPBTools (UserDefaults)


+ (id)getUserDefault:(NSString *)key
{
    if (key == nil)
    {
        return nil;
    }
    
    id value = [MPT_UserDefaults valueForKey:key];
    
    return value;
}

+ (BOOL)boolForKey:(NSString *)key
{
    if (key == nil)
    {
        return NO;
    }
    
    return [MPT_UserDefaults boolForKey:key];
}

+ (void)saveUserDefault:(NSString *)key value:(id)value
{
    if (key == nil ||
        value == nil)
    {
        return;
    }
    
    NSUserDefaults *defaults = MPT_UserDefaults;
    [defaults setObject:value forKey:key];
    [defaults synchronize];
}

+ (void)setBool:(BOOL)value forKey:(NSString *)key
{
    if (key == nil)
    {
        return;
    }
    
    NSUserDefaults *defaults = MPT_UserDefaults;
    [defaults setBool:value forKey:key];
    [defaults synchronize];
}

+ (void)removeObjectForKey:(NSString *)key
{
    if (key == nil)
    {
        return;
    }
    
    [MPT_UserDefaults removeObjectForKey:key];
}


@end
